<!-- 物流线路 - 表单编辑页面 -->
<template>
  <div class="page-container">

    <!-- title -->
<!--    <div class="page-content-title">-->
<!--        {{$tt('label_current_position')}}：{{ $tt('third_login_config') }}-->
<!--    </div>-->

    <el-form ref="formEl" :model="formValue" label-width="130px" class="common-form-panel-div">

      <!-- 产品基础信息 -->
      <ex_header_spiler title="第三方登陆配置"></ex_header_spiler>
      <el-row style="margin-top: 20px;">
        <el-col>
          <el-form-item label="开启第三方登陆">

            <el-switch
              v-model="formValue.status"
              active-value="ENABLE"
              inactive-value="DISABLED"
              >
            </el-switch>

          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <el-form-item label="第三方平台类型">
            <el-select v-model="formValue.loginType" placeholder="请选择" style="width:100%;">
              <el-option label="企业微信" value="WECHAT"></el-option>
              <el-option label="钉钉" value="DINGDING"></el-option>
              <el-option label="飞书" value="FEISHU"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col >
          <el-form-item label="企业id">
            <el-input v-model="formValue.wechatConfig.cropId"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col >
          <el-form-item label="agentId">
            <el-input v-model="formValue.wechatConfig.agentId"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col >
          <el-form-item label="secret">
            <el-input v-model="formValue.wechatConfig.secret"></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="2">
          <el-form-item label="通讯录同步配置">

            <div style="display: flex; width: 100%; justify-content: space-around; gap:10px;">
              <div>Secret</div>
              <div>Token</div>
              <div>EncodingAESKey</div>
            </div>
            <div style="display: flex; width: 100%; justify-content: space-around; gap:10px;">
              <div style="flex:1;"><el-input v-model="formValue.wechatConfig.syncSecret" style="width: 100%;"></el-input></div>
              <div style="flex:1;"><el-input v-model="formValue.wechatConfig.notifyToken" style="width: 100%;"></el-input></div>
              <div style="flex:1;"><el-input v-model="formValue.wechatConfig.notifyAesKey" style="width: 100%;"></el-input></div>
            </div>

          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="3">
          <el-form-item label="通讯录同步url">
<!--            <div style="color: #606266;">-->
<!--              域名： {{currentHost}}-->
<!--            </div>-->
            <div style="color: #606266;">
              {{currentHost}}/ums-api/user/ThirdLoginConfigRpc/wechat_callback.json
<!--              通讯录同步url： -->
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row >
        <el-col>
          <el-form-item label="">

            <el-switch
              v-model="formValue.defaultShowThirdLogin"
              active-text="默认显示扫码登陆页"
              active-value="Y"
              inactive-value="N"
              >
            </el-switch>

<!--            -->
<!--            <el-switch-->
<!--              v-model="formValue.defaultShowThirdLogin"-->
<!--              active-value="Y"-->
<!--              inactive-value="N"-->
<!--            >-->
<!--            </el-switch>-->

          </el-form-item>
        </el-col>
      </el-row>

      <el-row style="margin-top: 20px;">
        <el-col >
          <el-form-item >
            <!-- 提 交 -->
            <el-button type="primary" @click="submitForm()">{{ $tt('label_submit') }}</el-button>
            <!-- 返 回 -->
            <el-button @click="return_page_back()">{{ $tt('label_cancel') }}</el-button>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>

  </div>
</template>
<script>

  import router_params from '@/mixin/router_params';
  import insurance_price_cfg from '@/component/pms/insurance_price_cfg.vue'

  let moduleName = "保险产品"

  export default {

    title: 'third_login_config',
    components: {insurance_price_cfg},
    mixins: [router_params],


    data() {

      return {
        "currentHost": '',
        "formValue": {
          "wechatConfig": {}
        }
      };
    },

    created() {
      let _this = this


      _this.currentHost = window.location.protocol  + "//"+ window.location.host

      _this.$ajax({
        url: '/ums-api/user/ThirdLoginConfigRpc/getConfig.json',
        success: (res) => {
          if(res && res.data){
            _this.formValue = res.data
          }
          else{
            _this.$message({
              type: 'error',
              message: 'data error'
            })
          }
        }
      });

    },

    mounted() {

    },
    methods: {


      submitForm() {

        let _this = this


        this['$refs']['formEl'].validate((valid) => {


          if (valid) {
            this.$ajax({
              url: '/ums-api/user/ThirdLoginConfigRpc/updateConfig.json',
              type: 'json',
              data: _this.formValue,
              success: (responseData) => {
                this.$message({
                  showClose: true,
                  message: '提交成功',
                  type: 'success'
                })
              }
            });
          }


        });
      },

      goback() {
        this.$tag.tagClose()
      },


    }
  };

</script>
